﻿using System.Windows;
using System.Windows.Controls;
using Microsoft.Phone.Controls;
using Microsoft.Phone;
using System;
using VanGuideWP7.ViewModel;
using VanGuideWP7.DataLoader;
using System.Windows.Navigation;
using System.ComponentModel.Composition;

namespace VanGuideWP7.View
{
    /// <summary>
    /// Description for Details.
    /// </summary>
    public partial class DetailsPage : PhoneApplicationPage
    {
        /// <summary>
        /// Initializes a new instance of the Details class.
        /// </summary>
        public DetailsPage()
        {
            InitializeComponent();

            //init composition
            CompositionInitializer.SatisfyImports(this);
            DataContext = this.DetailsViewModel;
        }

        [Import(typeof(DetailsViewModel))]
        public DetailsViewModel DetailsViewModel { get; set; }

        private void abibTag_Click(object sender, EventArgs e)
        {
            if (!this.DetailsViewModel.Loading)
                DetailsViewModel.AddTagToPoi.Execute(DetailsViewModel.Pin);
        }

        private void abibComment_Click(object sender, EventArgs e)
        {
            if (!this.DetailsViewModel.Loading)
                DetailsViewModel.AddCommentToPoi.Execute(DetailsViewModel.Pin);
        }

        private void StarRatings_RatingSelected(object sender, int rating)
        {
            if (!this.DetailsViewModel.Loading)
                DetailsViewModel.AddRatingToPoi.Execute(rating);
                
        }
    }
}